<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<meta charset="UTF-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> 
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<title>采集界面</title>
	<link rel="stylesheet" href="${pageContext.request.contextPath}/lib/layui/css/layui.css">
</head>
<body>
<form class="layui-form">
	<div class="layui-row">
		<div class="layui-form-item">
			<div class="layui-col-xs10 layui-col-sm10 layui-col-md10">
				<label class="layui-form-label">发票密码:</label>
				<div class="layui-input-block">
					<input type="text" name="pwdValue" id="pwdValue" lay-verify="required"
						placeholder="请输入发票密码，例如：123456" maxlength="7" autocomplete="off" onkeyup="value=value.replace(/[^\d]/g,'') " ng-pattern="/[^a-zA-Z]/" class="layui-input">
					<button type="button" class="layui-btn" id="pwdQuery">密码查询</button>
				</div>
			</div>
		</div>
		<div class="layui-form-item">
			<div class="layui-col-xs10 layui-col-sm10 layui-col-md10">
				<label class="layui-form-label">发票类型:</label>
				<div class="layui-input-block">
					<input type="text" name="ticketType" id="ticketType" lay-verify="required"
						placeholder="请输入发票类型" maxlength="20" autocomplete="off"  class="layui-input">
					<!-- <select name="ticketType" id="ticketType" lay-verify="required">
						<c:forEach items="${typeDicDataArr}" var="typeDicData">
				        	<option value="${typeDicData.dicDataValue}">${typeDicData.dicDataName}</option>
				        </c:forEach>
					</select> -->
				</div>
			</div>
		</div>
		<div class="layui-form-item">
			<div class="layui-col-xs10 layui-col-sm10 layui-col-md10">
				<label class="layui-form-label">车牌号码:</label>
				<div class="layui-input-block">
					<input type="text" name="invoiceNum" id="invoiceNum" lay-verify="required"
						placeholder="请输入车牌号码，例如：沪123456" maxlength="6" autocomplete="off" onkeyup="value=value.replace(/[^\d]/g,'') " ng-pattern="/[^a-zA-Z]/" class="layui-input">
				</div>
			</div>
		</div>
		<div class="layui-form-item">
			<div class="layui-col-xs10 layui-col-sm10 layui-col-md10">
				<label class="layui-form-label">所属区域:</label>
				<div class="layui-input-block">
					<input type="text" name="areaId" id="areaId" lay-verify="required"
						placeholder="请输入所属区域" maxlength="20" autocomplete="off"  class="layui-input">
					
					<!-- <select name="areaId" id="areaId" lay-verify="required">
						<c:forEach items="${areaDicDataArr}" var="areaDicData">
				        	<option value="${areaDicData.dicDataValue}">${areaDicData.dicDataName}</option>
				        </c:forEach>
					</select> -->
				</div>
			</div>
		</div>
		<div class="layui-form-item">
			<div class="layui-col-xs10 layui-col-sm10 layui-col-md10">
				<label class="layui-form-label">所属单位:</label>
				<div class="layui-input-block">
					<input type="text" name="invoiceNum" id="invoiceNum" lay-verify="required"
						placeholder="请输入所属单位" maxlength="6" autocomplete="off" onkeyup="value=value.replace(/[^\d]/g,'') " ng-pattern="/[^a-zA-Z]/" class="layui-input">
				</div>
			</div>
		</div>
		<div class="layui-form-item">
			<div class="layui-col-xs5 layui-col-sm5 layui-col-md5">
				<label class="layui-form-label">车辆净重:</label>
				<div class="layui-input-block">
					<input type="text" name="netWeight" id="netWeight" lay-verify="required"
						placeholder="请输入车辆净重，例如：1234kg" maxlength="10" autocomplete="off"  class="layui-input">
				</div>
			</div>
			<div class="layui-col-xs5 layui-col-sm5 layui-col-md5">
				<label class="layui-form-label">车辆毛重:</label>
				<div class="layui-input-block">
					<input type="text" name="roughWeight" id="roughWeight" lay-verify="required"
						placeholder="请输入车辆毛重，例如：456789kg" maxlength="10" autocomplete="off"  class="layui-input">
				</div>
			</div>
			<!-- <div class="layui-col-xs10 layui-col-sm10 layui-col-md10">
				<label class="layui-form-label">当前时间:</label>
				<div class="layui-input-block">
					<input type="text" name="invoiceNum" id="invoiceNum" lay-verify="required"
						placeholder="请输入车辆毛重，例如：456789kg" maxlength="6" autocomplete="off" onkeyup="value=value.replace(/[^\d]/g,'') " ng-pattern="/[^a-zA-Z]/" class="layui-input">
				</div>
			</div> -->
		</div>
		<div class="layui-form-item">
			<div class="layui-input-block">
				<button type="button" class="layui-btn" id="submit_btn">信息确认</button>
			</div>
		</div>
	</div>
</form>
</body>
<script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script>
<script src="${pageContext.request.contextPath}/lib/layui/layui.all.js"></script>
<script>
var ctx = "${pageContext.request.contextPath}";
var layer = layui.layer;

var unitDicDatas = eval('${unitDicDatas}');
var areaDicDatas = eval('${areaDicDatas}');
var typeDicDatas = eval('${typeDicDatas}');

var areaId = "";
var ticketType = "";
var carNo = "";
var netWeight = "";
var roughWeight = "";
var unit = "";

function getDicVal(value,list){
	for(var i=0;i<list.length;i++){
		if(list[i].dicDataValue==value){
			return list[i].dicDataName;
		}
	}
	return "";
}
$(function(){
	
	$("#pwdQuery").on("click",function(){
		var pwdValue = $("#pwdValue").val();
		var index = layer.open({
		  type: 3
		});
		$.ajax({
		  type: 'POST',
		  url: ctx+"/app/findByNew",
		  data: {
			  pwdValue:pwdValue
		  },
		  success: function(data){
			  layer.close(index);
			  if(data && data.state=="SUCCEED"){
				  areaId = data.areaId;
				  ticketType = data.ticketType;
				  roughWeight = data.roughWeight;
				  netWeight = data.netWeight;
				  carNo = data.carNo;
				  unit = data.unit;
				  $("#areaId").val(getDicVal(areaId,areaDicDatas));
				  $("#ticketType").val(getDicVal(ticketType,typeDicDatas));
				  $("#roughWeight").val(data.roughWeight);
				  $("#netWeight").val(data.netWeight);
				  $("#carNo").val(data.carNo);
			  }else{
				  layer.msg(data.msg, {
						time: 30000, //20s后自动关闭
				        btn: ['确定']
				      });
			  }
		  },
		  error:function(data){
			  layer.close(index);
		  }
		});
	});
	
	
	
	$("#submit_btn").on("click",function(){
		var pwdValue = $("#pwdValue").val();
		var index = layer.open({
		  type: 3
		});
		$.ajax({
		  type: 'POST',
		  url: ctx+"/app/findByNew",
		  data: {
			  pwdValue:$("#pwdValue").val(),
			  areaId:areaId,
			  ticketType:ticketType,
			  roughWeight:roughWeight,
			  netWeight:netWeight,
			  carNo:carNo,
			  unit:unit
		  },
		  success: function(data){
			  layer.close(index);
			  layer.msg(data.msg, {
					time: 30000, //20s后自动关闭
			        btn: ['确定']
			      });
			  if(data && data.state=="SUCCEED"){
				  
			  }else{
				  
			  }
		  },
		  error:function(data){
			  layer.close(index);
		  }
		});
	});
	
	
	
	
	
});





</script>
</html>